/*
 * MemoryGray16Image
 *
 * Copyright (c) 2003 Marco Schmidt.
 * All rights reserved.
 */

namespace Petra.Gis.Geometry.Image.Tiff
{
  /**
   * An implementation of {@link Gray16Image} that keeps the complete image in memory.
   * This class inherits most of its functionality from its parent class
   * {@link MemoryShortChannelImage}, using one <code>short</code> channel.
   * @since 0.11.0
   * @author Marco Schmidt
   */
  public class MemoryGray16Image : MemoryShortChannelImage, IGray16Image
  {
    /**
     * Creates a new MemoryGray16Image object with the specified resolution.
     * Simply gives <code>1</code> (for one channel) and the two resolution arguments
     * to the super constructor (of the parent class {@link MemoryShortChannelImage}).
     * @param width the horizontal resolution, must be larger than zero
     * @param height the vertical resolution, must be larger than zero
     */
    public MemoryGray16Image(ImageFileDirectory ifd, int width, int height)
      : base(ifd, 1, width, height)
    { }




    public override IPixelImage createCompatibleImage(int width, int height)
    {
      return new MemoryGray16Image(_ifd, width, height);
    }




    public System.Type getImageType()
    {
      return typeof(IGray16Image);
    }




    public bool isBlack(int x, int y)
    {
      return getShortSample(x, y) == 0;
    }




    public bool isWhite(int x, int y)
    {
      return getShortSample(x, y) == (short)-1;
    }




    public void putBlack(int x, int y)
    {
      putSample(x, y, 0);
    }



    public void putWhite(int x, int y)
    {
      putSample(x, y, 65535);
    }
  }
}